import ajax from "./ajax.js";
let connect = document.querySelectorAll('.I1');
ajax.get(`http://localhost:8000/getAppoint?id=${getQueryVariable("id")}`, (value)=>{
    // const data = JSON.parse(value);
    // // console.log(data);
    // const { _id, goodsName, goodsDetails, price, number } = data;
    // connect[0].value = _id;
    // connect[1].value = goodsName;
    // connect[2].value = goodsDetails;
    // connect[3].value = price;
    // connect[4].value = number;
});
function getQueryVariable(variable) {
    //获取当前URL中的查询字符串部分（即问号后面的部分）
    var query = window.location.search.substring(1);
    //把查询字符串按照&符号分割成数组
    var vars = query.split("&");
    //遍历数组中的每个元素
    for (var i = 0; i < vars.length; i++) {
        //把当前元素按照=符号分割成键和值
        var pair = vars[i].split("=");
        //如果当前元素的键等于参数名，则返回对应的值
        if (pair[0] == variable) {
            return pair[1];
        }
    }
    //如果没有找到匹配的参数名，则返回false
    return false;
}



// const x = new XMLHttpRequest();
// x.open('get', `http://localhost:8000/getAppoint?id=${getQueryVariable("id")}`);
// x.send();
// x.onreadystatechange = () => {
//     if (x.readyState === 4 && x.status === 200) {
//         // console.log(x.response);
//         const data = JSON.parse(x.response);
//         const { _id, goodsName, goodsDetails, price, number } = data;
//         connect[0].value = _id;
//         connect[1].value = goodsName;
//         connect[2].value = goodsDetails;
//         connect[3].value = price;
//         connect[4].value = number;
//     }
// }